package com.stylefeng.guns.core.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Random;

/**
 * @author zhouh
 * @Date 2017/10/23.
 */
public class OrderUtil {

    /**
     * 生成订单号
     * @return
     */
    public static String makeTransId(){
        Date currTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA);
        String TradeDate = formatter.format(currTime); // 订单日期
        String b= (Math.abs(new Random().nextLong()) % 10000)+"";
        int lastLen=5-b.length();
        System.err.println("makeTransId:"+b);
        for (int i = 0; i < lastLen; i++) {
            Random rd = new Random();//产生随机数
            b+=rd.nextInt(10);
        }
        String transId = TradeDate+"c"+b;
        return transId;
    }
}
